package POJO;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

@Entity
@Table(name = "USER_ROLE", uniqueConstraints = {
		@UniqueConstraint(columnNames = { "Role", "User_Name"})
})
public class UserRole {
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "User_Role_Id", unique = true, nullable = false)
	private int userRoleId;
	
	@Column(name = "Role", nullable = false, length = 45)
	private String role;
	
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "User_Name", nullable = false)
	private User user;

	public UserRole() {
		super();
	}

	public UserRole(User user, String role) {
		super();
		this.role = role;
		this.user = user;
	}

	public int getUserRoleId() {
		return userRoleId;
	}

	public void setUserRoleId(int userRoleId) {
		this.userRoleId = userRoleId;
	}

	public String getRole() {
		return role;
	}

	public void setRole(String role) {
		this.role = role;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}
}
